<template>
	<view>
		<view class="header">
		</view>
		<form id="root" @submit="formSubmit">
			<view class="title">
				<view class="num">客户编码</view>

				<view class="name">客户名称</view>
			</view>
			<view>
				<view class="con-list">
					<radio-group class="radio-group" @change="radioChange(item)" v-for="(item,index) in listDictItems" :key="index">
						<label  class="contentd">
							<view class="kuang">
								<radio :value="item.operationCode" :checked="item.checked" />
							</view>
							<view class="num-value">{{item.operationCode}}</view>
							<view class="name-value">{{item.operationName}}</view>
						</label>
					</radio-group>
				</view>

			</view>
				<button class="fott" form-type="submit">确定</button>

		</form>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				bgColor: 'bg-green',
				gongxuList: [],
				listDictItems:[],
				kunnrList:{},
				indexGongxu:'',
				order:{},
				value: '',
				range: [],
			}
		},
		onShow() {
			this.getFactory()
		},
		methods: {
			getFactory(){
				let url = '/dcloud/dict/getDictItems'
				this.$http.post(url, {
						'table': 'bp000',
						'text': 'name1',
						'code': 'partnr',
						'keyword': '',
						'fields': ['name1', 'partnr', 'sort1'],
					
				}).then(res => {
					if (res && res.data.result) {
						this.listDictItems = [];
						res.data.result.forEach(v=>{
							var template = {operationCode:v.value,operationName:v.text};
							this.listDictItems.push(template);
						});
					}
				}).catch(err => {
					console.log(err);
				});
			},
			radioChange: function(e) {
				 const items = this.listDictItems
				    for (let i = 0, len = items.length; i < len; i++) {
				      items[i].checked = items[i].operationCode === e.operationCode
					  if(items[i].operationCode === e.operationCode){
						  this.order = items[i];
					  }
				    }
				this.listDictItems = items;
				// 设置选中的客户
				this.kunnrList = this.order;
				uni.setStorageSync('kunnr', this.kunnrList);
			},
			formSubmit:function(e){//返回上一层
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.kunnrList = this.kunnrList;
				uni.navigateBack({
					delta:1
				})
				
			},
		}
	}
</script>

<style lang="scss">
	.uni-list-cell {
		justify-content: flex-start
	}
	.con-list {
		background-color: #FFFFFF;
	}
	.title {
		display: flex;
		flex-direction: row;
		width: 100%;
		background-color: #FFFFFF;
		height: 100rpx;
		font-size: 28px;
	}

	.contentd {
		display: flex;
		flex-direction: row
	}

	.num {
		width: 20%;
		text-align: center;
		line-height: 100rpx;
		margin-left: 150rpx;
	}

	.name {
		width: 60%;
		line-height: 100rpx;
		text-align: center;
	}

	.num-value {
		width: 20%;
		text-align: center;
		margin-left: 40rpx;
		line-height: 100rpx;

	}

	.name-value {
		width: 100%;
		margin-left: 100rpx;
		line-height: 100rpx;
		text-align: center;
	}
	.kuang {
		width: 20%;
		margin-left: 50rpx;
		line-height: 100rpx;
		text-align: center;
	}

	.fott {
		  border-radius:0;
		  position: fixed;
		  bottom: 0;
		  display: flex;
		  width: 100%;
		  justify-content: center;
	}
	.header {
		display: flex;
		flex-direction: row;
		padding: 10px 15px;
		align-items: center;
		/* background-color: #b6bbc3; */
		background-image: linear-gradient(#34A4DF, #34A4DF, #2bace7);
	}

	.icon {
		display: flex;
		flex-direction: column;
		justify-content: center;
		margin-left: 10px;
	}
</style>
